use std::fmt::Display;

fn main() {
    println!("{}", List(vec![1, 2, 3]))
}

#[derive(Debug)]
struct List(Vec<i32>);

impl Display for List {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        let vec = &self.0;

        write!(f, "[")?;

        for (count, v) in vec.iter().enumerate() {
            println!("count {} {} end", count, v);
            if count != 0 {
                write!(f, "，")?;
            }

            write!(f, "{}", v)?;
        }

        write!(f, "]")
    }
}
